(function($){
    $.stars = function(el, arg1, arg2, options){
        // To avoid scope issues, use 'base' instead of 'this'
        // to reference this class from internal events and functions.
        var base = this;
        
        // Access to jQuery and DOM versions of element
        base.$el = $(el);
        base.el = el;
        
        // Add a reverse reference to the DOM object
        base.$el.data("stars", base);
        
        base.init = function(){
            base.arg1 = arg1;
            base.arg2 = arg2;
            
            base.options = $.extend({},$.stars.defaultOptions, options);
            
            // Put your initialization code here
        };
        
        // Sample Function, Uncomment to use
        // base.functionName = function(paramaters){
        // 
        // };
        
        // Run initializer
        base.init();
    };
    
    $.stars.defaultOptions = {
        rated: false,
        stars: 5,
        step: 1,
        val: 0,
        img: "jStars.png",
        imgw: 28,
        imgh: 28,
        onchange: "function(v){}",
        onrating: "function(v){}"
    };
    
    $.fn.stars = function(arg1, arg2, options){
        return this.each(function(){
            (new $.stars(this, arg1, arg2, options));
        });
    };
    
    // This function breaks the chain, but returns
    // the stars if it has been attached to the object.
    $.fn.getstars = function(){
        this.data("stars");
    };
    
})(jQuery);
